// Custom variables

// Because !default means that a variable is not assigned if it already contains a value,
// we alter the variable before importing boostrap as _variables.scss will use !default

@import "../../../../../node_modules/bootstrap/scss/bootstrap";
@import "modules/_sizes.scss";
@import "bootstrap-switch.scss";
@import "codemirror.scss";

$top-nav-height: 49px;
$footer-height: 40px;
$left-navigation-width: 260px;
$left-navigation-width-when-compact: 48px;
$border-content: 1px solid #DEDEDE;
$link-padding-left: 16px !default;

html, body {
    background-color: #FFF;
}


@mixin word-wrap() {
    overflow-wrap: break-word;
    word-wrap: break-word;
    -ms-word-break: break-all;
    word-break: break-all;
    word-break: break-word;
    -ms-hyphens: auto;
    -moz-hyphens: auto;
    -webkit-hyphens: auto;
    hyphens: auto;
}

body {
    margin-bottom: $footer-height;
}

.left-sidebar-compact .ta-footer {
    width: calc(100% - 60px);
    transition: width 0.2s ease-in-out, width 0.2s ease-in-out;
}

.ta-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    width: calc(100% - 260px);
    height: $footer-height;
    line-height: $footer-height;
    background-color: $gray-100;
    z-index: 8;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    transition: width 0.2s ease-in-out, width 0.2s ease-in-out;
    font-size: .7rem;
}

// Layout
// -----------------------------


// Layout 1 : ta-navbar-top
// -----------------------------

.ta-navbar-top {
    @extend .navbar, .navbar-expand-md, .navbar-light, .fixed-top;
    height: $top-nav-height;
    border-bottom: $border-content;
    z-index: $zindex-sticky;
    padding-left: 0px;
    background-color: white;

    .nav-link {
        font-size: 14px;
    }
}


.ta-navbar-brand {
    @extend .navbar-brand;
    overflow: hidden;
    width: 230px;
    height: 42px;
    margin-left: 11px;
    margin-right: 24px;
    padding-left: 36px;
    padding-top: 10px;
    background-image: url(../logo.png);
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 28px auto;
    white-space: nowrap;
    font-size: 14px;
    transition: width 0.2s ease-in-out;

    span:first-child {
        margin-left: 5px;
    }

    span:last-child {
        font-weight: bold;
        color: rgba(0,120,212,1);
    }
}


// When left-sidebar is compact nav brand is compacted too.
// It displays logo only, not text.
.left-sidebar-compact .ta-navbar-brand {
    width: 30px;
    height: 42px;

    span {
        display: none;
    }
}



// Layout 2 : ta-content
// -----------------------------

.ta-content {
    padding: 15px;
    margin-left: $left-navigation-width;
    margin-top: $top-nav-height;
    margin-bottom: $footer-height;
    transition: margin-left 0.2s ease-in-out;

    h1 {
        line-height: 40px;
        font-size: 28px;
        letter-spacing: -.04em;
        font-weight: bold;
    }
}

.left-sidebar-compact .ta-content {
    margin-left: $left-navigation-width-when-compact;
}

@include media-breakpoint-down(sm) {
    .ta-content {
        margin-left: $left-navigation-width-when-compact;
        transition: margin-left 0.5s ease-in-out;
    }
}

// Layout 3 : ta-left-sidebar when expanded
// ----------------------------------------

body:not(.left-sidebar-compact) {
    #ta-left-sidebar {
        background-color: #EAEAEA;
        z-index: 7;
        position: fixed;
        top: $top-nav-height;
        bottom: 0;
        left: 0px;
        width: $left-navigation-width;
        color: $gray-800;
        border-right: $border-content;
        transition: left 0.2s ease-in-out, width 0.2s ease-in-out;
        font-family: "Segoe UI VSS (Regular)","Segoe UI","-apple-system",BlinkMacSystemFont,Roboto,"Helvetica Neue",Helvetica,Ubuntu,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
        // Rotate the chevron's icon when the menu is active
        label[aria-expanded="true"] {
            .chevron {
                transform: rotate(90deg);
                transition-duration: 0.2s;
            }
        }

        label[aria-expanded="false"] {
            .chevron {
                transition-duration: 0.2s;
            }
        }

        .collapse {
            display: none;
        }

        .collapse.show {
            display: block;
        }

        .chevron {
            position: absolute;
            top: 38%;
            left: 100%;
            margin-left: -25px;
        }

        label, a {
            position: relative;
            display: block;
            margin: 0;
        }

        #left-nav {
            position: relative;
            height: calc(100% - 50px);

            ul {
                margin: 0;
                padding: 0;
                white-space: nowrap;
            }

            > ul {

                li {
                    position: relative;
                    margin: 0;
                    padding: 0;
                    display: list-item;
                    list-style: none;

                    .item-label {
                        cursor: pointer;
                    }
                }

                > li {
                    line-height: 3em;
                    width: $left-navigation-width;
                    transition: width 0.2s ease-in-out;
                    background-color: #EAEAEA;

                    &:first-child:after {
                        content: "";
                        width: 92%;
                        height: 1px;
                        background: rgba(0, 0, 0, 0.1);
                        display: block;
                        margin: 0px auto 4px auto;
                        position: absolute;
                        left: 10px;
                    }
                }

                > li > ul > li {
                    line-height: 2.5em;
                }
                // first level menu items that have no items and are active
                > li.active:not(.has-items)::before {
                    border-left: 3px solid;
                    border-left-color: #0078D4;
                    bottom: 0;
                    content: "";
                    left: 0;
                    position: absolute;
                    top: 0;
                }
                // changing the padding of the icons on the first level to match
                // the padding when leftbar is collapsed. Avoid small movement
                // when switching between the two states
                &.menu-admin {
                    margin-bottom: 40px;

                    .item-label {
                        padding-left: 0px !important;
                        display: flex;

                        > span.icon {
                            padding: 0 5px;
                            flex-shrink: 0;
                            font-size: 22px;
                            width: $left-navigation-width-when-compact;

                            svg {
                                width: 35px;
                            }
                        }

                        > span.title {
                            flex-grow: 1;
                            font-size: 14px;
                            width: calc(100% - 48px - 45px);
                            overflow: hidden;
                            white-space: nowrap;
                            text-overflow: ellipsis;
                        }
                    }

                    > li > .item-label > .collapse-icon {
                        color: rgba(255, 0, 0, 0);
                        display: flex;
                        justify-content: center;
                    }
                }
            }

            ul li .item-label, li a:hover, li a:active, li a:visited {
                color: $gray-700;
                text-decoration: none;
                padding-left: $link-padding-left;
            }

            .btn-nostyle {
                background: none;
                color: inherit;
                border: none;
                padding: 0;
                font: inherit;
                cursor: pointer;
                width: 45px;
                outline: none;
            }
            //for accessibility testing
            /*.btn-nostyle:focus, .btn-nostyle:active {
                background-color: rgba(0, 0, 0, 0.3);
                color: white;
            }*/
        }


        li.has-items .item-label,
        li.has-items a:hover,
        li.has-items a:active,
        li.has-items a:visited {
            padding-left: $link-padding-left - 4px;
        }

        li .item-label:hover {
            background-color: rgba(0, 0, 0, 0.1);
        }

        li > ul > li.active > .item-label {
            background: rgba(0, 0, 0, 0.1);
            color: rgba(0,0,0,.9) !important;
            font-weight: 600;
            padding-left: (2 * $link-padding-left + 16) !important;
        }

        li.active > ul > li.active > .item-label::before {
            border-left: 3px solid;
            border-left-color: #0078D4;
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.active > ul > li > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.has-items.active > .item-label {
            padding-left: (2 * $link-padding-left + 16) !important;
        }

        li.has-items.active > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,0.1);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.active > .item-label {
            background-color: rgba(0, 0, 0, 0.05);
            font-weight: 600;
        }

        li.active > .item-label:hover {
            background-color: rgba(0, 0, 0, 0.1);
        }

        li .active::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,0.05);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li .active .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,0.1);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li ul > li {
            > .item-label {
                background: rgba(0,0,0,0.05);
                color: $gray-700 !important;

                > span.icon {
                    font-size: 16px !important;
                }
            }
        }

        li.active ul > li > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li ul > li ul > li {
            background: rgba(0,0,0,.1);
        }
        // third level indent
        li ul > li ul > li > a {
            color: black;
            padding-left: 3 * $link-padding-left !important;
        }

        li ul > li ul > .active > a {
            padding-left: (3 * $link-padding-left - 4) !important;
        }

        .footer {
            background-color: #EAEAEA !important;
            position: relative;
            z-index: 1;
        }

        .footer:before {
            content: "";
            width: 92%;
            height: 1px;
            background: rgba(0, 0, 0, 0.1);
            display: block;
            margin: 0px auto;
        }
    }
}
// Layout 4 : ta-left-sidebar when compacted
// -----------------------------------------
.left-sidebar-compact {

    #ta-left-sidebar {
        background-color: #EAEAEA;
        z-index: $zindex-sticky;
        position: fixed;
        top: $top-nav-height;
        bottom: 0;
        left: 0px;
        width: $left-navigation-width-when-compact;
        color: $gray-800;
        border-right: $border-content;
        transition: left 0.2s ease-in-out, width 0.2s ease-in-out;
        font-family: "Segoe UI VSS (Regular)","Segoe UI","-apple-system",BlinkMacSystemFont,Roboto,"Helvetica Neue",Helvetica,Ubuntu,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
        // Rotate the chevron's icon when the menu is active
        label[aria-expanded="true"] {
            .chevron {
                transform: rotate(90deg);
                transition-duration: 0.2s;
            }
        }

        label[aria-expanded="false"] {
            .chevron {
                transition-duration: 0.2s;
            }
        }

        .collapse {
            display: none;
        }

        .collapse.show {
            display: block;
        }

        .chevron {
            position: absolute;
            top: 38%;
            left: 100%;
            margin-left: -25px;
        }

        label, a {
            position: relative;
            display: block;
            margin: 0;
        }

        #left-nav {
            position: relative;
            height: calc(100% - 50px);

            ul {
                margin: 0;
                padding: 0;
                white-space: nowrap;
                background-color: $gray-100;
            }

            > ul {

                li {
                    position: relative;
                    margin: 0;
                    padding: 0;
                    display: list-item;
                    list-style: none;

                    .item-label {
                        cursor: pointer;
                    }
                }

                > li {
                    line-height: 3em;
                    width: $left-navigation-width-when-compact - 1;
                    transition: width 0.2s ease-in-out;
                    background-color: #EAEAEA;

                    &:first-child > span.title:after {
                        content: "";
                        width: 75%;
                        height: 1px;
                        background: rgba(0,0,0,.1);
                        display: block;
                        margin: 0px auto 4px auto;
                    }
                }

                > li > ul > li {
                    line-height: 2.5em;
                }
                // changing the padding of the icons on the first level to match
                // the padding when leftbar is collapsed. Avoid small movement
                // when switching between the two states
                &.menu-admin {
                    margin-bottom: 40px;
                }

                .item-label {
                    padding-left: 0px !important;
                    display: flex;

                    > span.icon {
                        padding: 0 5px;
                        flex-shrink: 0;
                        font-size: 16px;

                        svg {
                            width: 27px;
                        }
                    }

                    > span.icon-none {
                        flex-shrink: 0;
                        font-size: 16px;
                        width: 37px;
                    }

                    > span.title {
                        flex-grow: 1;
                        font-size: 14px;
                        width: calc(100% - 48px);
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                }

                > li > .item-label > .collapse-icon {
                    color: rgba(255, 0, 0, 0);
                    display: flex;
                    justify-content: center;
                }


                > li > .item-label {
                    .icon:hover {
                        background-color: rgba(0, 0, 0, 0.1);
                    }

                    .title:hover {
                        color: $gray-100;
                        background-color: rgba(0, 0, 0, 0.1);
                    }
                }

                > li.active:not(.has-items) > .item-label::before {
                    border-left: 3px solid;
                    border-left-color: #0078D4;
                    bottom: 0;
                    content: "";
                    left: 0;
                    position: absolute;
                    top: 0;
                }

                > li .item-label:hover:not(:first-child) {
                    color: $gray-100;
                    background-color: rgba(0, 0, 0, 0.1);
                }
                // formatting of icons
                > li > .item-label > span.icon {
                    display: inline-block !important;
                    color: $gray-700;
                    background-color: #EAEAEA;
                    width: $left-navigation-width-when-compact;
                }

                > li.has-items.active > .item-label::before {
                    border-left: 3px solid;
                    border-left-color: #0078D4;
                    bottom: 0;
                    content: "";
                    left: 0;
                    position: absolute;
                    top: 0;
                }

                > li.has-items.visible {
                    -webkit-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    -moz-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    z-index: 1;
                }

                li .active > .item-label:hover {
                    background-color: rgba(0, 0, 0, 0.1);
                }

                > li {
                    overflow: hidden;

                    span.title {
                        display: none;
                    }
                }

                > li.visible {
                    overflow: visible;
                    width: $left-navigation-width-when-compact + $left-navigation-width;
                    transition: none;

                    span.title, span.icon {
                        display: block;
                    }
                }

                > li > ul {
                    position: absolute;
                    left: $left-navigation-width-when-compact;
                    width: $left-navigation-width;
                    -webkit-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    -moz-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
                    max-height: 250px;
                    z-index: -1;
                }

                > li > ul li .item-label:hover {
                    background-color: rgba(0, 0, 0, 0.05);
                }

                > li > .item-label {
                    background-color: $gray-100;
                    color: $gray-700;
                    padding-left: 0px !important;
                    display: flex;

                    .title {
                        padding: 0 20px;

                        &:hover {
                            background-color: $gray-100 !important;
                            color: $gray-700;
                        }
                    }

                    > span.icon {
                        padding: 0 5px;
                        flex-shrink: 0;
                        font-size: 22px;
                        width: $left-navigation-width-when-compact;

                        svg {
                            width: 35px;
                        }
                    }

                    > span.title {
                        flex-grow: 1;
                        font-size: 14px;
                        font-weight: bold;
                        width: calc(100% - 48px);
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }

                    > span.title:after {
                        content: "";
                        height: 1px;
                        background: rgba(0, 0, 0, 0.1);
                        display: block;
                        margin: 0px auto;
                        position: absolute;
                        width: 75%;
                        left: 63px;
                    }
                }
                // first level menu items that have no items and are active
                > li.active:not(.has-items)::before {
                    border-left: 3px solid;
                    border-left-color: #0078D4;
                    bottom: 0;
                    content: "";
                    left: 0;
                    position: absolute;
                    top: 0;
                }

                > li > label {
                    .btn-nostyle {
                        display: none;
                    }
                }
            }

            ul li .item-label, li a:hover, li a:active, li a:visited {
                text-decoration: none;
                padding-left: $link-padding-left;
            }

            .btn-nostyle {
                background: none;
                color: inherit;
                border: none;
                padding: 0;
                font: inherit;
                cursor: pointer;
                width: 45px;
                outline: none;
            }
            //for accessibility testing
            /*.btn-nostyle:focus, .btn-nostyle:active {
                background-color: rgba(0, 0, 0, 0.3);
                color: white;
            }*/
        }

        li.has-items .item-label,
        li.has-items a:hover,
        li.has-items a:active,
        li.has-items a:visited {
            padding-left: $link-padding-left - 4px;
        }

        li > ul > li.active > .item-label {
            background: rgba(0, 0, 0, 0.05);
            color: rgba(0,0,0,.9) !important;
            font-weight: 600;
            padding-left: (2 * $link-padding-left + 16) !important;
        }

        li.active > ul > li.active > .item-label::before {
            border-left: 3px solid;
            border-left-color: #0078D4;
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.active > ul > li > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.has-items.active > .item-label {
            padding-left: (2 * $link-padding-left + 16) !important;
        }

        li.has-items.active > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li.active > .item-label {
            background-color: rgba(0, 0, 0, 0.1);
            font-weight: 600;
        }

        li .active::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.1);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li .active .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li ul > li > .item-label {
            color: $gray-700 !important;
        }

        li.active ul > li > .item-label::before {
            border-left: 3px solid;
            border-left-color: rgba(0,0,0,.2);
            bottom: 0;
            content: "";
            left: 0;
            position: absolute;
            top: 0;
        }

        li ul > li ul > li {
            background: rgba(0,0,0,.1);
        }
        // third level indent
        li ul > li ul > li > a {
            color: black;
            padding-left: 3 * $link-padding-left !important;
        }

        li ul > li ul > .active > a {
            padding-left: (3 * $link-padding-left - 4) !important;
        }

        .footer {
            background-color: #EAEAEA !important;
            position: relative;
            z-index: 1;
        }

        .footer:before {
            content: "";
            width: 60%;
            height: 1px;
            background: rgba(0,0,0,.1);
            display: block;
            margin: 0px auto;
        }
    }
}

// fixing a flickering that occurs on compact leftbar while icons load.
html:not(.fontawesome-i2svg-complete) #left-nav ul.menu-admin > li > .item-label {
    background-color: $gray-100 !important;
}
// Layout 5 : leftbar compactor button
// -----------------------------------
.leftbar-compactor {
    display: block;
    width: $left-navigation-width-when-compact;
    height: 50px;
    padding: 10px;
    border: none;
    background-color: transparent;
    color: $gray-700;
    cursor: pointer;
    font-size: 20px;
    float: right;
    transition-duration: 0.2s;
    display: block;
    transform: scale(2,1);

    &:focus {
        outline: none;
    }

    &:hover {
        color: rgba(0,120,212,1);
        color: var(rgba(0, 120, 212, 1));
        text-shadow: 0 0 4px rgba(0,120,212,.5);
    }

    &:before {
        content: "\0027EA";
    }
}

.left-sidebar-compact .leftbar-compactor {
    transition-duration: 0.2s;
    transform: scale(-2, 1);
}

.auth-wrapper {
    width: 100%;
    max-width: 800px;
    margin: auto;
}
// Layout 6 : login layout
// -----------------------------------
.ta-content-login {
    margin-left: 0;
}

.auth-form {
    label {
        display: block;
    }
}
// END OF LAYOUT
// -----------------------------
// Forms
// -----------------------------
.hint {
    @extend .small, .text-muted;
    @include word-wrap;
}

.validation-summary-errors {
    @extend .alert, .alert-danger;
    padding-bottom: 0;
}

.field-validation-error {
    @extend small, .invalid-feedback;
}

.input-validation-error {
    @extend .is-invalid;
}

.has-validation-error {
    @extend .is-invalid;
}

.inline-form {
    display: inline;
}

.code, .form-control.code {
    font-family: $font-family-monospace;
    font-size: $code-font-size;
    padding: $kbd-padding-y $kbd-padding-x;
    color: $pre-color;
    @include border-radius($border-radius);
}

.label-link {
    float: right;
    font-size: 12px;
}
// When the validation message in inside the label, add a separator
label .field-validation-error::before {
    content: "- ";
}

.button {
    @extend .btn, .btn-primary;
}

.field-validation-valid {
    display: none;
}

select[multiple] {
    min-height: 300px;
}
// Toolbar
// ------------------------------
.admin-toolbar {
    @extend .navbar, .navbar-expand-md, .navbar-light;
    margin-bottom: 1em;
    background-color: $gray-200;
}
// Messages
// ------------------------------
.message {
    @extend .alert;
}

.message-success {
    @extend .alert-success;
}

.message-information {
    @extend .alert-info;
}

.message-warning {
    @extend .alert-warning;
}

.message-error {
    @extend .alert-danger;
}
// Pager
// ------------------------------
ul.pager {
    @extend .pagination;
    margin-top: 1rem;
}

ul.pager li {
    @extend .page-item;
}

ul.pager li a {
    @extend .page-link;
}
// Sortable
// ------------------------------
.ui-sortable-handle {
    cursor: move;
}

.btn.ui-sortable-handle {
    cursor: move !important;
}

.ui-sortable {
    min-height: $font-size-base;
}

.properties {
    @extend .w-100;
}

.related {
    @extend .float-right;
}
// Responsive sizes
// Creates mixins to target all breakpoints
// ------------------------------
.col-xs {
    @extend .col-8, .col-sm-4, .col-md-3, .col-lg-2, .col-xl-1;
}

.col-sm {
    @extend .col-12, .col-sm-9, .col-md-6, .col-lg-3, .col-xl-3;
}

.col-md {
    @extend .col-12, .col-sm-12, .col-md-10, .col-lg-8, .col-xl-6;
}

.col-lg {
    @extend .col-12, .col-sm-12, .col-md-12, .col-lg-12, .col-xl-9;
}

.col-xl {
    @extend .col-12, .col-sm-12, .col-md-12, .col-lg-12, .col-xl-12;
}
// No transitions on load
// Prevents Firefox and Edge transitions on load.
// This class is added by default and removed trought Javascript
// after a few milliseconds.
// https://css-tricks.com/transitions-only-after-page-load/
// ------------------------------
.preload * {
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -ms-transition: none !important;
    -o-transition: none !important;
}

.persona {
    position: relative;
    text-align: center;
    height: 48px;
    width: 48px;
    flex: 0 0 auto;

    &.small {
        width: 24px;
        height: 24px;
    }

    .persona-content {
        border-radius: 50%;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        color: white;

        &.small {
            font-size: 11px;
            line-height: 24px;
        }
    }
}
